import Conf from "@/config/dict"

function Format(){
  this.list = {};
}

Format.prototype.init = function(type){
  let callback = this.list[type];
  return new Promise((resolve)=>{
    let res = [];
    if(!callback){
      console.log(`WEB-DICT: dict hasnt function of ${type}`)
    }else{
      if(Object.prototype.toString.call(callback) !== "[object Function]"){
        res = callback;
      }else{
        res = callback(type);
      }
    }
    resolve(res)
  })
}

Format.prototype.add = function(type,fun){
  this.list[type] = fun;
}

let format = new Format();
Conf(format);
export default format;

